<?php
/**
 * User: @lixu
 * Date: 2019-05-28
 * Time: 11:10
 */

use Biz\service\wiki\TagList as sTagList;

class TagListAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_NOTHING;

    public function main()
    {
        $params = $this->getRequest()->getQuery('params', []);
        $sortType = $this->getRequest()->getQuery('sort_type', 0);
        $page = $this->getRequest()->getQuery('page', 0);
        $page = $page < 1 ? 1 : abs($page);

        $params = json_decode($params, true);

        if($params && $params['tag']) {
            $tag = $params['tag'];
            $params = $params['params'];
        } else {
            throw new \Exception('tag不存在');
        }

        $list = sTagList::getList($tag, $params, $sortType, $page, $this->uid);

        $list = \Doraemon\tools\StatSign::versionCompatible($list, \Doraemon\tools\StatSign::WIKI_UP_GRADE_VERSION_522, \Doraemon\tools\BlockType::TYPE_WIKI, 'wiki' );
        $this->setSuccess($list);
    }
}